<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/signin.css" rel="stylesheet">
    <script src="/js/boom.js"></script>
    <script src="/dist/layui.js"></script>
    <style>
        .col-2{
            padding-top: 7px;
        }
        .form-check{
            padding-left: 7rem;
        }
        .form-group{
            margin-left: 5rem;
        }
        .align-middle{
            margin-left: 16rem;
            margin-bottom: 2rem;
        }
        .btn{
            margin-left: 10rem;
        }
        video{
          position: fixed;
          right:0;
          bottom: 0;
          min-width: 100%;
          min-height: 100%;
          width: auto;
          height: auto;
          z-index: -9999;
          /*灰色调*/
          /*-webkit-filter:grayscale(100%)*/
        }
        .rounded{
            background-color:rgba(224, 204, 204, 0)
        }
       
    </style>
</head>

<body>

    <video id="v1" autoplay muted loop style="width: 100%">
        <source  src="/videos/Raphael LAcoste.mp4">
    </video>
    <div class="container">
        <div class="row align-items-center">
            <div class="col">

            </div>
            <div class="col">
               
                <div class="alert alert-danger alert-dismissible fade show invisible text-center" style="width: 42rem;"
                    role="alert">
                   
               
                </div>
            </div>
            <div class="col">

            </div>

        </div>
        <div class="row align-items-center" style="height: 25rem;">
            <div class="col">
                
            </div>
            <div class="col">
                <div class="card shadow rounded" style="width: 40rem; height: 22rem;">
                    <div class="card-body align-items-center">
                        <h2 class="align-middle" >登录</h2>
                        <form id="loginForm">
                            
                            <div class="form-group row">
                                <label class="col-2" for="exampleInputEmail1">用户名：</label>
                                <input type="text" class="form-control col-6" name="username" id="username"
                                    aria-describedby="emailHelp">
                                <small id="emailHelp" class="form-text text-muted">
                                    
                                   </small>
                            </div>
                            <div class="form-group row">
                                <label class="col-2" for="exampleInputPassword1">密码：</label>
                                <input type="password" class="form-control col-6" name="password" id="password">
                            </div>
                            <div class="form-group form-check row">

                                    <input type="checkbox" class="form-check-input" id="exampleCheck1">
                                    <label class="form-check-label" for="exampleCheck1">记住我</label>
                                                <div style="margin-left: 10rem; ">忘记密码？点击这里↓</div> 
                            </div>
                            
                            <button type="button" class="btn btn-primary" onclick="jump()">登录</button>
                            <button type="button" class="btn btn-primary" onclick="register()">注册</button>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col">
                
            </div>
        </div>
      
    </div>

    <!-- 备案号 -->
    <div style="position:fixed; bottom:15px; width:100%; text-align:center;"a href="http://beian.miit.gov.cn">
        <div><a href="http://beian.miit.gov.cn" class="icp" > 皖ICP备2020018722号</a></p>
        </div>
        <img width="20" height="20" src="/imgs/备案图标.png" style="margin-right: 260px;">
        <div style="position:fixed; bottom:0px; width:100%; text-align:center; color:rgb(76, 76, 218)"><a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11010502030143"> 闽公网安备 35058102000233号</a></p>
           
        </div>
            </div>

            <script src="/dist/layui.js"></script>

    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script> clickEffect(); //调用事件函数</script>
    <script>
        function register(){
            window.location.href='/register';
        }
        // 点击注册时 执行的方法（获取数据，进行初步验证，验证通过则通过ajax向后台提交数据；否则提示验证不通过的信息）
        function jump() {
            let username = $('#username').val();
            let password = $('#password').val();
            if (username.length > 0 && password.length > 0) {
                // ajax请求
                $.ajax({
                    url: "/loginDone",
                    type: "POST",
                    data: $('#loginForm').serialize(),
                    dataType: "json",
                    success: function (res) {
                        console.log(res);
                        if(res.code===200){
                            window.location.href="/";
                        }else{
                            alert_fn(res.msg);
                        }
                        
                    },
                    error: function (msg) {
                        alert_fn('网络或者服务器有问题');
                    }
                })
            } else {// 验证不通过，阻止提交
                alert_fn('用户名和密码不能为空');
                return false;
            }
        }

        // 这个方法包装了alert的相关行为和显示的内容
        function alert_fn(msg) {
            msg=msg || '密码不能为空，两次密码应该一致';
            // 替换提示的内容
            $('#msg').text(msg);
            // 移除不显示的class，则alert将显示
            $('.invisible').removeClass('invisible');
            // 三秒中后，给alert增加不显示的class，则alert重新隐藏
            setTimeout(() => {
                $('.alert').addClass('invisible');
            }, 3000);
        }
    </script>
</body>

</html>